package com.zyl.demo.mapper;

import com.zyl.demo.beans.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Select("SELECT * FROM t_category")
    List<Category> getAllCategory();

    @Select("SELECT * FROM t_category  ORDER BY category_id LIMIT 0,3")
    List<Category> getCategoryTopThree();

    @Insert("insert into t_category(category_name,category_describe,category_img) values(#{categoryName},#{categoryDescribe},#{categoryImg})")
    int addCategory(Category category);

    @Delete("delete from t_category where category_id=#{categoryId}")
    int deleteCategory(int categoryId);

}
